import React, { Component } from 'react'
import Comment from '../Comment/Comment'
export default class CommentList extends Component {
	static defaultProps = {
		comments: [],
	}
	_getProcessedContent(content) {
		return content
			.replace(/&/g, '&amp;')
			.replace(/</g, '&lt;')
			.replace(/>/g, '&gt;')
			.replace(/"/g, '&quot;')
			.replace(/'/g, '&#039;')
			.replace(/`([\S\s]+?)`/g, '<code>$1</code>')
	}
	render() {
		return (
			<div>
				{/* 顶部显示文字 */}
				<div
					dangerouslySetInnerHTML={{
						__html: this._getProcessedContent('<p>11111111</p>'),
					}}
				></div>
				{this.props.comments.map((comment, i) => (
					<Comment
						handelDel={this.props.handelDel}
						comment={comment}
						key={i}
					/>
				))}
			</div>
		)
	}
}
